package com.goexcursion


class UserService {

	User create(String email){
		User user = new User(email:email )
		user.save()
		return user
	}
	
	User update(Long userId, String email){
		def user = User.get(userId)
		user.email = email
		user.save()
	}
	
	def delete(Long userId){
		def user = User.get(userId)
		if(user)
			user.delete()
		else
			throw new RuntimeException("User does not exist")
	}
	
	def get ( Long id){
		return User.get(id)
	}
}
